package LessonPlans
{
	import LessonPlans.Tasks.Task;
	
	import flash.filesystem.File;

	public class AbstractLessonPlan implements ILessonPlan
	{
		private var _teacherName:String;
		private var _date:Date;
		private var _title:String;
		private var _taskList:Vector.<Task>;
		
		public function AbstractLessonPlan(title:String,teacherName:String,date:Date)
		{
			_teacherName = teacherName;
			_title = title;
			_date = date;
			_taskList = new Vector.<Task>();
		}
		
		public function addTask(task:Task):void
		{
			_taskList.push(task);
		}
		
		public function get date():Date
		{
			if(isNaN(_date.time))
				_date = new Date();
			return _date;
		}
		
		public function get taskList():Vector.<Task>
		{
			return _taskList;
		}
		
		public function get teacherName():String
		{
			return _teacherName;
		}
		
		public function get title():String
		{
			if(_title==null||_title=="")
				_title="untitled";
			return _title;
		}
		
		public function set title(title:String):void
		{
			_title=title;
		}
		
		public function toString():String
		{
			var tasks:String="";
			for each(var t:Task in _taskList)
			{
				tasks+=t.toString()+flash.filesystem.File.lineEnding;
			}
			
			return "Title: "+_title+flash.filesystem.File.lineEnding+"Teacher Name: "+_teacherName+
				flash.filesystem.File.lineEnding+tasks;
		}
	}
}